package com.chenfan.ccp.executor.wrapper;

import java.util.concurrent.Callable;

/**
 * 封装Callable接口
 * @author wulg
 * @date 2022-04-26
 **/
public class CallableWrapper<T> extends AbstractWrapper implements Callable<T> {

    private Callable<T> callable;

    public CallableWrapper(Callable<T> callable) {
        this.callable = callable;
    }

    @Override
    public T call() throws Exception {
        try {
            this.copy();
            return callable.call();
        } finally {
            this.clear();
        }
    }
}
